import React, { Component, PureComponent } from 'react'
import './Demo.scss'
/**
 * 浅比较的算法
 * 
 */
export default class Demo2 extends PureComponent {
  constructor(){
    super()
    this.state={
        list:[1,2,3,4,5]
    }
  }
  shouldComponentUpdate(){
    return true
  }
  render() {
    return (
      <div className='box'>
         {
            this.state.list.map((item,index)=><div key={index} className='item'>{item}</div>)
         }
         <div className='add' onClick={()=>{
            // this.state.list.push(6)
            // this.setState({list:this.state.list})
            this.setState({
                list:[...this.state.list,6]
            })
         }}>+</div>
      </div>
    )
  }
}
